﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using HP.Cachalote.DataModels;
using HP.Cachalote.Repositories.Interfaces;

namespace HP.Cachalote.UnitTests.FakeRepositories
{
    public class FakeRepositoryFactory : IRepositoryFactory
    {
        public void OpenSessionWithTransaction() { }

        public void OpenSession() { }

        public void Rollback() { }

        public void Commit() { }

        public void Flush() { }

        public void CloseSession() { }

        public IRepository<T> CreateRepositoryBase<T>() where T : DataModels.DataModelBase
        {
            if (typeof(T) == typeof(TodoLabel))
            {
                return (IRepository<T>)CreateTodoLabelRepository();
            }
            else if (typeof(T) == typeof(TodoItem))
            {
                return (IRepository<T>)CreateTodoItemRepository();
            }
            else
            {
                return null;
            }
        }

        public ITodoLabelRepository CreateTodoLabelRepository()
        {
            return new FakeLabelRepository();
        }

        public ITodoItemRepository CreateTodoItemRepository()
        {
            return new FakeItemRepository();
        }

        public void Dispose() { }
    }
}
